package com.zhuiyun.educations.api.member.controller;

import com.zhuiyun.educations.api.member.entity.Member;
import com.zhuiyun.educations.api.member.service.MemberService;
import com.zhuiyun.educations.common.controller.BaseController;
import com.zhuiyun.educations.common.response.CommonResult;
import com.zhuiyun.educations.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName MemberVoController
 * @Description TODO 会员类型管理
 * @Author ys
 * @Date 2023/6/16 8:25
 **/
@Slf4j
@RestController
@Api(tags = "会员管理")
@RequestMapping("/member")

public class MemberController extends BaseController {
    @Resource
    private MemberService memberService;
    /**
     * @Author ys
     * @Description TODO 分页查询
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @GetMapping("/getMember")
    @ApiOperation(value = "会员管理的分页查询方法")
    public CommonResult getMember(PageRequest pageRequest){
        log.info("分页查询");
        return memberService.getMember(pageRequest);
    }
    /**
     * @Author ys
     * @Description TODO 新增
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @PostMapping("/addMember")
    @ApiOperation(value = "会员管理的添加方法")
    public CommonResult addMember(@RequestBody Member member){
        log.info("添加");
        return memberService.addMember(member);
    }
    /**
     * @Author ys
     * @Description TODO 修改
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @PutMapping("/updateMember")
    @ApiOperation(value = "会员管理的修改方法")
    public CommonResult updateMember(@RequestBody Member member){
        log.info("修改");
        return memberService.updateMember(member);
    }
    /**
     * @Author ys
     * @Description TODO 修改状态
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @PutMapping("/updatestate")
    @ApiOperation(value = "会员管理的修改状态方法")
    public CommonResult updatestate(@RequestBody Member member){
        log.info("修改状态");
        return memberService.updatestate(member);
    }
    /**
     * @Author ys
     * @Description TODO 逻辑删除
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @DeleteMapping("/deleteMemberById")
    @ApiOperation(value = "会员管理的逻辑删除方法")
    public CommonResult deleteMemberById(int id){
        log.info("逻辑删除");
        return memberService.deleteMemberById(id);
    }
    /**
     * @Author ys
     * @Description TODO 批量逻辑删除
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @PostMapping("/deleteMemberByIds")
    @ApiOperation(value = "会员管理的批量逻辑删除方法")
    public CommonResult deleteMemberByIds(@RequestBody List<String> ids){
        log.info("批量逻辑删除");
        return memberService.deleteMemberByIds(ids);
    }
}
